package com.lxy.demo.manager;

import com.lxy.demo.cache.Clear;
import com.lxy.demo.log.LoggerTest;
import com.lxy.demo.sec.Security;
import org.springframework.stereotype.Service;

/**
 * 问题：
 *   1.代码重复，不够优化, 不好维护
 *   2.核心模块和非核心模块耦合
 */

//核心功能的实现类 - A同学
    @Service("ccb")
public class CCBManagerImpl implements CCBManager {

    Security security = new Security();
    LoggerTest loggerTest = new LoggerTest();
    Clear clear = new Clear();

    //核心方法
    @Override
    public void changeMoney() {
        //安全模块
        //security.isSecurity();
        System.out.println("CCBManagerImpl...changeMoney()...恭喜你，转账成功！");
        //日志模块
        //loggerTest.log();
        //清除缓存模块
        //clear.clearCache();
    }

    //核心方法
    @Override
    public void selectMoney() {
        //安全模块
        //security.isSecurity();
        System.out.println("CCBManagerImpl...selectMoney()...余额查询成功！剩余2000亿！");
        //日志模块
        //loggerTest.log();
        //清除缓存模块
        //clear.clearCache();
    }

    //核心方法
    @Override
    public void invest() {
        //安全模块
        //security.isSecurity();
        System.out.println("CCBManagerImpl...invest()...恭喜你，投资失败！剩余2块！");
        //日志模块
        //loggerTest.log();
        //清除缓存模块
        //clear.clearCache();
    }

    //核心方法
    @Override
    public String getUserName(String name) {
        //安全模块
        //security.isSecurity();
        System.out.println("CCBManagerImpl...getUserName()...用户信息查询成功！");
        //日志模块
        //loggerTest.log();
        //清除缓存模块
        //clear.clearCache();
        return "账户信息：" + name;
    }
}
